import $axios, { Result } from '@/plugins/axios'
import { AxiosResponse } from 'axios'
import { PageParam } from '@/type'

export async function getAllUnit(): Promise<AxiosResponse<Result>> {
  return await $axios.post(`/supervision-api/unit/getAllUnit`)
}

/**
 * 删除单位/负责部门
 * @param ids id字符串，逗号分隔
 */
export async function deleteUnit(ids: string): Promise<AxiosResponse<Result>> {
  return await $axios.delete(`/supervision-api/unit/deleteUnit/${ids}`)
}

/**
 * 新增/修改参会单位
 * @param data 参会单位信息
 */
export async function addOrUpdateUnit(
  data: any,
): Promise<AxiosResponse<Result>> {
  return await $axios.post(`/supervision-api/unit/addOrUpdateUnit`, data)
}

/**
 * 懒加载查询组织机构下的科室
 * @param param.node 父级id
 */
export async function getUnitByLazy(
  param: PageParam,
): Promise<AxiosResponse<Result>> {
  return await $axios.post('/supervision-api/unit/getUnitByLazy', param)
}

/**
 * 分页查询组织机构下的科室
 */
export async function getUnitByPage(
  param: PageParam,
): Promise<AxiosResponse<Result>> {
  return await $axios.post('/supervision-api/unit/getUnitByLazyAndPage', param)
}
